/* Markdown 样式优化 */
.markdown-content {
  position: relative;
  display: inline-block;
  padding: 16px 20px;
  border-radius: 12px;
  background: #f8fbff;
  box-shadow: 0 2px 12px rgba(58, 122, 254, 0.08);
  margin-bottom: 4px;
  width: 100%;
  max-width: 85%;
  font-family:
    -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  line-height: 1.6;
  color: #2d3748;
}

/* 标题样式 */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin: 1.5em 0 0.8em;
  color: #1a365d;
  font-weight: 600;
  line-height: 1.4;
  scroll-margin-top: 2em;
}

.markdown-content h1 {
  font-size: 1.8em;
}
.markdown-content h2 {
  font-size: 1.6em;
}
.markdown-content h3 {
  font-size: 1.4em;
}
.markdown-content h4 {
  font-size: 1.2em;
}
.markdown-content h5 {
  font-size: 1.1em;
}
.markdown-content h6 {
  font-size: 1em;
}

/* 段落和列表样式 */
.markdown-content p {
  margin: 1em 0;
  line-height: 1.8;
  color: #2d3748;
}

.markdown-content ul,
.markdown-content ol {
  margin: 1em 0;
  padding-left: 2em;
}

.markdown-content li {
  margin: 0.5em 0;
  line-height: 1.6;
}

/* 代码块样式 */
.markdown-content pre {
  position: relative;
  margin: 1.5em 0;
  padding: 0;
  background: #f6f8fa;
  border-radius: 8px;
  overflow: hidden;
}

.markdown-content pre code {
  display: block;
  padding: 1em;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.95em;
  line-height: 1.6;
  overflow-x: auto;
  background: #f6f8fa;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(58, 122, 254, 0.08);
}

/* 代码块语言标签 */
.markdown-content pre code::before {
  content: attr(data-language);
  display: block;
  padding: 0.5em 1em;
  background: #e2e8f0;
  color: #4a5568;
  font-size: 0.9em;
  font-weight: 500;
  border-bottom: 1px solid #cbd5e0;
}

/* 代码块复制按钮 */
.markdown-content pre .copy-button {
  position: absolute;
  top: 0.5em;
  right: 0.5em;
  padding: 0.25em 0.5em;
  background: #e2e8f0;
  border: none;
  border-radius: 4px;
  font-size: 0.9em;
  color: #4a5568;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

.markdown-content pre:hover .copy-button {
  opacity: 1;
}

.markdown-content pre .copy-button:hover {
  background: #cbd5e0;
}

/* 行内代码样式 */
.markdown-content code:not(pre code) {
  padding: 0.2em 0.4em;
  margin: 0 0.2em;
  font-size: 0.9em;
  background: #f1f5f9;
  border-radius: 4px;
  color: #2563eb;
  font-family: 'Fira Code', 'Consolas', monospace;
}

/* 表格样式 */
.markdown-content table {
  width: 100%;
  margin: 1.5em 0;
  border-collapse: collapse;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(58, 122, 254, 0.08);
}

.markdown-content th,
.markdown-content td {
  padding: 0.75em 1em;
  border: 1px solid #e2e8f0;
  text-align: left;
}

.markdown-content th {
  background: #f8fafc;
  font-weight: 600;
  color: #1a365d;
}

.markdown-content tr:nth-child(even) {
  background: #f8fafc;
}

/* 引用块样式 */
.markdown-content blockquote {
  margin: 1.5em 0;
  padding: 1em 1.5em;
  border-left: 4px solid #3a7afe;
  background: #f0f7ff;
  border-radius: 0 8px 8px 0;
  color: #2d3748;
}

.markdown-content blockquote p {
  margin: 0;
}

/* 分割线样式 */
.markdown-content hr {
  margin: 2em 0;
  border: none;
  border-top: 2px solid #e2e8f0;
}

/* 链接样式 */
.markdown-content a {
  color: #3a7afe;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: all 0.2s;
}

.markdown-content a:hover {
  border-bottom-color: #3a7afe;
  color: #2563eb;
}

/* 图片样式 */
.markdown-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  margin: 1.5em 0;
  box-shadow: 0 2px 8px rgba(58, 122, 254, 0.08);
  transition: transform 0.2s;
}

.markdown-content img:hover {
  transform: scale(1.02);
}

/* 强调样式 */
.markdown-content strong {
  font-weight: 600;
  color: #1a365d;
}

.markdown-content em {
  font-style: italic;
  color: #4a5568;
}

/* 任务列表样式 */
.markdown-content input[type='checkbox'] {
  margin-right: 0.5em;
}

/* 代码块滚动条样式 */
.markdown-content pre code::-webkit-scrollbar {
  height: 8px;
}

.markdown-content pre code::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

.markdown-content pre code::-webkit-scrollbar-thumb {
  background: #cbd5e0;
  border-radius: 4px;
}

.markdown-content pre code::-webkit-scrollbar-thumb:hover {
  background: #a0aec0;
}

/* 响应式处理 */
@media (max-width: 768px) {
  .markdown-content {
    padding: 12px 16px;
    max-width: 100%;
  }

  .markdown-content table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }

  .markdown-content pre {
    margin: 1em -1em;
    border-radius: 0;
  }

  .markdown-content pre code {
    font-size: 0.9em;
    padding: 0.8em;
  }

  .markdown-content img {
    margin: 1em 0;
  }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
  .markdown-content {
    background: #1a202c;
    color: #e2e8f0;
  }

  .markdown-content h1,
  .markdown-content h2,
  .markdown-content h3,
  .markdown-content h4,
  .markdown-content h5,
  .markdown-content h6 {
    color: #f7fafc;
  }

  .markdown-content p {
    color: #e2e8f0;
  }

  .markdown-content pre {
    background: #2d3748;
  }

  .markdown-content pre code {
    background: #2d3748;
    color: #e2e8f0;
  }

  .markdown-content code:not(pre code) {
    background: #2d3748;
    color: #90cdf4;
  }

  .markdown-content blockquote {
    background: #2d3748;
    border-left-color: #4299e1;
    color: #e2e8f0;
  }

  .markdown-content table {
    background: #2d3748;
  }

  .markdown-content th {
    background: #2d3748;
    color: #f7fafc;
  }

  .markdown-content td {
    border-color: #4a5568;
  }

  .markdown-content tr:nth-child(even) {
    background: #2d3748;
  }
}
